/*
Copyright 2007 Raymond Giorgi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

package edu.pitt.CS2510.View;

import java.awt.Color;
import java.awt.Graphics;

/**
 * This class draws a line from one point to another Generally between two nodes
 * 
 * @author NoOne
 * 
 */
public class Connection extends Shape {

	private final int x2, y2;

	/**
	 * Sets the start and end points of the line
	 * 
	 * @param x1
	 * @param y1
	 * @param x2
	 * @param y2
	 */
	public Connection(int x1, int y1, int x2, int y2) {
		super(x1, y1);
		x += 10;
		y += 10;
		x2 = x2 * 20 + 10;
		y2 = y2 * 20 + 10;
		this.x2 = x2;
		this.y2 = y2;
		color = Color.white;
	}

	/**
	 * Get the end 'x' coordinate
	 * 
	 * @return
	 */
	public int getX2() {
		return x2;
	}

	/**
	 * Get the end 'y' coordinate
	 * 
	 * @return
	 */
	public int getY2() {
		return y2;
	}

	/**
	 * Draw the line
	 */
	@Override
	void draw(Graphics g) {
		g.setColor(color);
		g.drawLine(getX(), getY(), getX2(), getY2());
	}
}
